<div class="blazorise-codeblock">
<div class="html"><pre>
<span class="atSign">&#64;</span>using System.Dynamic

<span class="htmlTagDelimiter">&lt;</span><span class="htmlElementName">DataGrid</span> <span class="htmlAttributeName">TItem</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">ExpandoObject</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName">Data</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">inMemoryData</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName">Responsive</span>
          <span class="htmlAttributeName">ShowPager</span>
          <span class="htmlAttributeName">ShowPageSizes</span>
          <span class="htmlAttributeName">PageSize</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">5</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName">Editable</span>
          <span class="htmlAttributeName">EditMode</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="enum">DataGridEditMode</span><span class="enumValue">.Inline</span><span class="quot">&quot;</span>
          <span class="htmlAttributeName">NewItemCreator</span><span class="htmlOperator">=</span><span class="quot">&quot;</span><span class="htmlAttributeValue">NewItemCreator</span><span class="quot">&quot;</span> <span class="htmlTagDelimiter">/&gt;</span>
</pre></div>
<div class="csharp"><pre>
<span class="atSign">&#64;</span>code {
    [Inject] EmployeeData EmployeeData { <span class="keyword">get</span>; <span class="keyword">set</span>; }

    <span class="keyword">private</span> List&lt;ExpandoObject&gt; inMemoryData;

    <span class="keyword">protected</span> <span class="keyword">override</span> <span class="keyword">async</span> Task OnInitializedAsync()
    {
        inMemoryData = <span class="keyword">new</span>();
        <span class="keyword">var</span> data = ( <span class="keyword">await</span> EmployeeData.GetDataAsync().ConfigureAwait( <span class="keyword">false</span> ) ).Take( <span class="number">25</span> );

        <span class="keyword">foreach</span> ( <span class="keyword">var</span> item <span class="keyword">in</span> data )
        {

            IDictionary&lt;<span class="keyword">string</span>, <span class="keyword">object</span>&gt; expando = <span class="keyword">new</span> ExpandoObject();

            <span class="keyword">foreach</span> ( <span class="keyword">var</span> property <span class="keyword">in</span> <span class="keyword">typeof</span>( Employee ).GetProperties() )
            {
                expando.Add( property.Name, property.GetValue( item ) );
            }
            inMemoryData.Add( (ExpandoObject)expando );
        }


        <span class="keyword">await</span> <span class="keyword">base</span>.OnInitializedAsync();
    }

    <span class="keyword">private</span> ExpandoObject NewItemCreator()
    {
        IDictionary&lt;<span class="keyword">string</span>, <span class="keyword">object</span>&gt; expando = <span class="keyword">new</span> ExpandoObject();

        <span class="keyword">foreach</span> ( <span class="keyword">var</span> property <span class="keyword">in</span> <span class="keyword">typeof</span>( Employee ).GetProperties() )
        {
            expando.Add( property.Name, property.PropertyType.IsValueType ? Activator.CreateInstance( property.PropertyType ) : <span class="keyword">null</span> );
        }

        <span class="keyword">return</span> (ExpandoObject)expando;
    }
}
</pre></div>
</div>
